<template>
  <div>
    <div class="uploadButton">
      <el-button type="primary" @click="dialogUploadVisible = true">上传资源</el-button>
      <div class="dialog">
        <el-dialog title="上传资源"
          v-loading="loading"
          element-loading-text="拼命上传中..."
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.8)"
         center :visible.sync="dialogUploadVisible">
          <el-upload
            class="upload-demo"
            ref="upload"
            drag
            :action="uploadurl"
            :http-request="uploadSectionFile"
            :file-list="fileList"
            :before-upload="beforeUpload"
            :on-change="handleChange"
            :auto-upload="false"
          >
            <!-- <el-button slot="trigger" type="primary">选取文件</el-button> -->
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或<em>点击选取</em></div>
          </el-upload>
          <div slot="footer" class="dialog-footer">
            <el-button
              style="margin-left: 10px;"
              type="success"
              @click="submitUpload"
            >上传<i class="el-icon-upload el-icon--right"></i></el-button>
            <el-button @click="dialogUploadVisible = false">取 消</el-button>
          </div>
        </el-dialog>
      </div>
    </div>

    <el-table :data="resourceList" :header-cell-style="{background:'#eef1f6',color:'#606266'}" stripe border style="width: 90%;margin:0 auto">
      <el-table-column sortable prop="id" width="80px" align="center" label="id"></el-table-column>
      <el-table-column align="center" label="文件名">
        <template slot-scope="scope">
          <el-button type="text" size="mini" @click="handlePlay(scope.$index, scope.row)">{{ scope.row.name }}</el-button>
      </template>
      </el-table-column>
      <el-table-column align="center" width="100px" prop="type" label="文件类型"></el-table-column>
      <el-table-column align="center" width="100px" :formatter="nameFormatter" prop="author" label="上传人"></el-table-column>
      <el-table-column :formatter="dataFormat" sortable align="center" width="160px" prop="createTime" label="上传时间"></el-table-column>
      <el-table-column width="120px" label="操作" align="center">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleDownload(scope.$index, scope.row)">下载</el-button>
          <el-button size="mini" type="text" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="block" style="margin-top:20px">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      background
      :current-page="currentPage"
      :page-sizes="[5,10, 15, 20]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
  </div>
</template>

<script src='./videolistjs.js'>
</script>

<style src="./videolist.css">
</style>